package com.sdl.auth.service.controller;

import com.sdl.auth.clients.CompetenceClient;
import com.sdl.common.base.entity.User;
import com.sdl.common.wrapper.WrapMapper;
import com.sdl.common.wrapper.Wrapper;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.security.Principal;
import java.util.Map;
import java.util.Set;

/**
 * @program flowerPaaS
 * @description:
 * @author: songdeling
 * @create: 2020/04/22 15:25
 */
@Api("认证")
@RestController
public class TestController {
    @Resource
    private CompetenceClient competenceClient;


    @PostMapping(value = "/test")
    public Wrapper principal(@RequestBody Map<String,Object> map,@RequestParam("str1") String str1) {
        Set<Map.Entry<String, Object>> entries = map.entrySet();
        String s = null;
        for (Map.Entry<String, Object> entry : entries) {
            s += "key:" + entry.getKey() + "value:" + entry.getValue();

        }
        s += str1;
        return WrapMapper.ok(s);
    }

    @GetMapping(value = "/getUser/{userName}")
    public Wrapper<User> getUser(@PathVariable String userName) {
        Wrapper<User> userByUsernameFromCTC = competenceClient.getUserByUsernameFromCTC(userName);
        return userByUsernameFromCTC;
    }
}
